﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;
using System.ComponentModel;
using System.Collections;
using System.Drawing.Design;

namespace Water.Web.Controls.Office.Excel
{
    [ToolboxItem(false)]
    //[ToolboxData("<{0}:Label runat=server></{0}:Label>")]
    public class Label
    {
        private string tilte;
        private int row=1;
        private int col=1;
        private string style;
        private int offsetRow;

        [Browsable(true), Category("Behavior"), GlobalizeDescription("SheetTilte")]
        public string Tilte
        {
            get { return Water.Web.Prompt.PromptProxy.GetPromptDesc(tilte); }
            set { tilte = value; }
        }

        [Browsable(true), Category("Behavior"), GlobalizeDescription("Row"),DefaultValue(1)]
        public int Row
        {
            get { return row; }
            set { row = value; }
        }

        [Browsable(true), Category("Behavior"), GlobalizeDescription("Col"), DefaultValue(1)]
        public int Col
        {
            get { return col; }
            set { col = value; }
        }

        [Browsable(true), Category("Behavior"), GlobalizeDescription("OffsetRow"), DefaultValue(0)]
        public int OffsetRow
        {
            get { return offsetRow; }
            set { offsetRow = value; }
        }

        [Browsable(true), Category("Appearance"), GlobalizeDescription("Style")]
        public string Style
        {
            get { return style; }
            set { style = value; }
        }
        public virtual void Render(HtmlTextWriter writer)
        {
            string _cell=Util.Util.GetCellName(Row,Col);
            string _label = Util.Label.CreateExcelLabel(_cell, Tilte, Style);
            writer.Write(_label);
        }
        public virtual void Render(HtmlTextWriter writer,Water.Web.Controls.Office.Excel.Util.QueryTable queryTable,int offset)
        {
            string _cell = "Cells(" + queryTable.Row + "+" + queryTable.VarCount + "+" + offset + "-1,"+Col+")";
            string _label = Util.Label.CreateExcelLabel(_cell, Tilte, Style);
            writer.Write(_label);
        }
    }
}
